<?php

namespace Analysis\Model;

use Think\Model;

class DisisbnModel extends Model
{
    protected $_validate = array(
        array('dis_custype', 'checkReturnVal', '请选择正确的推广类型', 0, 'callback'),
        array('dis_preid', 'checkReturnVal', '请选择正确的优惠方式', 0, 'callback'),
        array('dis_limitcode', 'checkReturnVal', '限制码错误', 0, 'callback')
    );
    protected $_auto = array(
        array("dis_isbn", "getISBN", 3, "callback"),
        array("dis_custype", "getCusType", 3, "callback"),
        array("dis_status", "getDisStatus", 3, "callback"),
        array('dis_time', 'time', 3, 'function'),
    );

    protected function checkReturnVal($data)
    {
        return $data == 0 ? false : true;
    }

    protected function getISBN()
    {
        return I("post.dis_custype") . I("post.dis_sn") . I("post.dis_endtimecode");
    }

    protected function getCusType()
    {
        return I("post.dis_custype");
    }

    protected function getDisStatus()
    {
        return I("post.dis_limitcode") == 1 ? 2 : 1;
    }

    private function sendMessTo($val, $mobile)
    {
        $info = D('Textchel')->getSmsParam($mobile, $val);
        $status = explode(",", $info);
        return $status == 0 ? true : false;
    }
}
